library(readxl)
library(dplyr)
library(tidyr)
library(countrycode)
library(ggplot2)
library(plotly)
library(leaflet)
library(maptools)
library(sp)
library(mapdata)
library(mice)
library(stargazer)In recent years, the world has become more connected than ever before. Globalization has brought us closer, whilst enabling free trade and increasing economic interdependence. This has improved physical infrastructures and opened up a world of new opportunities for individuals to seek better lives for themselves and their families. This rapid development has allowed access to better economic prospects, education and quality of life. As a result individuals are constantly migrating and settling in countries with better opportunity. The following plot aims to visualize this migration as it illustrates the Net Migration for each country in 2019. Here, a negative value for a country means there are more people leaving the country than entering it, while a positive value implies more people are entering the country.
#Net Migration Data
Net_Mgtn = read_excel('Net_Migration_Data.xls', sheet='Data') #Read Data
colnames(Net_Mgtn) = Net_Mgtn[3, ] #Rename Columns
Net_Mgtn = Net_Mgtn[-c(1:3), -c(3,4)] #Drop Unnecessary Columns
# Set ISO Code
Net_Mgtn$ISO_Code = countrycode(sourcevar = Net_Mgtn$`Country Name`, origin = "country.name", destination = "iso3c")
#Subset for SAARC Countries
NTMG_SARC = Net_Mgtn %>% select(c("Country Name","Country Code",
as.character(2000:2021))) %>% filter(
Net_Mgtn$`Country Code` %in% c('AFG', 'BGD', 'BTN',
'IND', 'MDV', 'NPL',
'PAK', 'LKA'))
# Pivot the dataframe longer for years
NTMG_SARC = pivot_longer(NTMG_SARC, cols = 3:ncol(NTMG_SARC),
names_to = "Year", values_to = "Net Migration")
#Convert Value to Numeric
NTMG_SARC$`Net Migration` = as.numeric(NTMG_SARC$`Net Migration`)
# Change Country Code column to ISO3 codes
NTMG_SARC$`Country Code` = countrycode(sourcevar = NTMG_SARC$`Country Name`, origin = "country.name", destination = "iso3c")#Visualization 1: World Map Net immigration 2021
## Filter Data fo 2019
Net_Mgtn_2019 = Net_Mgtn %>% filter(is.na(ISO_Code)==FALSE)%>% select(c("Country Name", "ISO_Code", "2019"))
Net_Mgtn_2019$`2019` = as.numeric(Net_Mgtn_2019$`2019`)
# Convert tbl_df object to data frame
Net_Mgtn_2019 = as.data.frame(Net_Mgtn_2019)
library(maps)
library(sf)
library(rgdal)
library(leaflet)
library(maptools)
library(rnaturalearth)
library(rnaturalearthdata)
library(htmltools)
# Load world map data from Natural Earth
world_map = ne_countries(scale = "medium", returnclass = "sf")
# Join the example data to the world map data
df_sf = merge(world_map, Net_Mgtn_2019, by.x = "iso_a3", by.y = "ISO_Code")
# Create the interactive map
leaflet() %>%
addTiles() %>%
addPolygons(data = df_sf, fillColor = ~colorFactor(palette = "Blues", domain = df_sf$`2019`)(`2019`),
fillOpacity = 0.7, color = "white", weight = 1,
highlightOptions = highlightOptions(color = "red", weight = 2,
bringToFront = TRUE),
label = (~paste0("Country: ", htmlEscape(`Country Name`), " Value: ", htmlEscape(`2019`)))) %>%
setView(lng = 0, lat = 50, zoom = 2)We can see that people tend to migrate from developing or undeveloped countries to developed countries. This intriguing phenomenon depicts the “brain drain” effect, where skilled workers or young people leaving their home countries in search of better opportunities. While this migration provides host countries with an abundance of skilled resources, it also leaves developing and underdeveloped countries in a worse state. This interesting outlook has formulated this report, which aims to explore the the factors that affect migration and its effect on the home countries. However, this report will solely focus on South Asian Countries (SAARC) to understand these diverse determinants and effect.
The past literature encompasses a range of studies that contribute to our understanding of migration and its effects on home countries. It highlights how increased connectivity and economic interdependence have led individuals to seek better opportunities in developed countries. The papers try to identify the causes for such migrations and also acknowledges that it has both positive and negative consequences.
Causes of brain drain and solutions: The Taiwan experience | Shirley L. Chang
The paper highlights various reasons behind brain drain in Taiwan. These factors include limited career opportunities, inadequate salary and benefits, a lack of research and development infrastructure, and insufficient recognition and rewards for talented individuals. Additionally, the influence of globalization and the appeal of better opportunities abroad are also discussed as driving forces behind brain drain.
The Impact of Remittance on Human Development | Aysen Ustubici, Darja Irdam
This paper explores the relationship between development and migration, specifically focusing on the impact of remittances on human development, as well as the effects of Foreign Direct Investment (FDI) and official development assistance (ODA). The findings indicate a positive correlation between remittances and human development in middle-income countries.
Is the Brain Drain Good for Africa? | William Easterly, Yaw Nyarko
The paper argues that the brain drain phenomenon in Africa is likely to have a net positive impact. It suggests that the brain drain’s effect on Africa’s skill gap is relatively small compared to other regions and that the gains experienced by migrants and their families through remittances outweigh the losses. The paper also asserts that the brain drain stimulates skill accumulation within Africa, offsetting the loss of skills.
Motivated by the existing literature on the topic, we start by collecting data on various indicators such as GDPC, HDI, Remittance, Net Migration, Literacy Rate, Unemployment, Foreign Direct Investment, Inflation, Corruption, Violence, Governance, and Median Population Age for Bhutan, Bangladesh, India, Maldives, Nepal, Pakistan, and Sri Lanka. Unfortunately, data for Afghanistan, which is also part of the SAARC alliance, could not be obtained and therefore is not included in the analysis. The data was sourced from the World Bank Data Bank, UNDP data bank, and Wikipedia through web scraping. Subsequently, these datasets were processed, filled if missing and merged to facilitate the creation of visualizations and regression analyses.
In this paper, we propose several hypotheses. Firstly, we hypothesize that unemployment, literacy rate, and corruption significantly contribute to the migration of individuals from these countries. Secondly, we contend that the migration and the resulting remittances have a positive impact on these countries rather than being disadvantageous. We aim to test and gain insights into these hypotheses through appropriate visualizations and regression analyses.
The following section aims to visually depict the migration patterns discussed in the aforementioned sections. To illustrate this phenomenon, the following plot showcases the Net Migration of people from South Asian Countries from 2000 to 2001.
#Visualization 2: SAARC Emigration over time 2000 to 2021
NTMG_SARC$Year = as.numeric(NTMG_SARC$Year)
p = plot_ly(NTMG_SARC%>%select(c("Country Name", "Year", "Net Migration"))) %>%
layout(title = list(text = "Net Migration by Country and Year"),
xaxis = list(title = list(text = "Year")),
yaxis = list(title = list(text = "Net Migration")))
p = add_lines(p, x=~Year, y = c(rep(0, 176)), line = list(color = "black", width=5, dash="dash"),
type = "scatter", mode = "lines", name="Zero Line")
# Set the visibility of the other lines to "legendonly"
for(i in 2:length(unique(NTMG_SARC$`Country Name`))) {
p = add_trace(p, data = subset(NTMG_SARC, `Country Name` == unique(NTMG_SARC$`Country Name`)[i]),
x = ~Year,
y = ~`Net Migration`,
color = ~`Country Name`,
type = 'scatter',
mode = 'lines',
name = unique(NTMG_SARC$`Country Name`)[i],
visible = ifelse(i == 2, 'visible', 'legendonly'),
showlegend = TRUE # set to FALSE for the other lines to be hidden
)
}
pThe line plot depicting the net migration of South Asian countries, including Bangladesh, Bhutan, India, Maldives, Nepal, Pakistan, and Sri Lanka, from 2000 to 2021 provides interesting insights. Firstly, Sri Lanka, India, Pakistan, and Bangladesh exhibit a similar migration pattern, with more people leaving these countries than entering since the early 2000s, as indicated by the negative net migration values. Even during the Covid-19 pandemic, when many individuals returned to their home countries, these countries still experienced negative net migration. In contrast, Nepal’s line plot demonstrates a significant influx of people in 2019-2020, likely influenced by the pandemic. This suggests that those leaving Nepal during this period may primarily consist of low-skilled workers unable to sustain living abroad amidst the global health crisis. Conversely, individuals migrating from India, Pakistan, Bangladesh, and Sri Lanka may be skilled workers who have successfully settled abroad. The plot also reveals a gradual increase in people leaving Nepal in 2021 when restrictions were eased. Bhutan, on the other hand, experienced a decline in net migration since 2004 but witnessed an upward trend from 2016, potentially attributed to government philosophies like Gross National Happiness and economic improvements. Nevertheless, Maldives stands out as the only South Asian country with a positive net migration, indicating a higher influx of people than emigration. This can be attributed to the thriving tourism industry, which offers employment opportunities and attracts both skilled and unskilled workers from other countries.
#Emigration Data
AFG_OECD_EMG = read_excel('AFG_OECD_EMG.xlsx')
BGD_OECD_EMG = read_excel('BGD_OECD_EMG.xlsx')
BTN_OECD_EMG = read_excel('BTN_OECD_EMG.xlsx')
MLD_OECD_EMG = read_excel('MLD_OECD_EMG.xlsx')
IND_OECD_EMG = read_excel('IND_OECD_EMG.xlsx')
NPL_OECD_EMG = read_excel('NPL_OECD_EMG.xlsx')
PAK_OECD_EMG = read_excel('PAK_OECD_EMG.xlsx')
SLK_OECD_EMG = read_excel('SLK_OECD_EMG.xlsx')
#Function to clean Emigration Data
clean_EMG = function(dat){
colnames(dat) = dat[3, ]
df = dat[-c(1:4), -c(2, 24)]
df[df == '..'] = '-1'
df[, 2:ncol(df)] = apply(df[, 2:ncol(df)], 2, as.numeric)
return(df)
}
AFG_OECD_EMG = clean_EMG(AFG_OECD_EMG)
BGD_OECD_EMG = clean_EMG(BGD_OECD_EMG)
BTN_OECD_EMG = clean_EMG(BTN_OECD_EMG)
MLD_OECD_EMG = clean_EMG(MLD_OECD_EMG)
IND_OECD_EMG = clean_EMG(IND_OECD_EMG)
NPL_OECD_EMG = clean_EMG(NPL_OECD_EMG)
PAK_OECD_EMG = clean_EMG(PAK_OECD_EMG)
SLK_OECD_EMG = clean_EMG(SLK_OECD_EMG)
##To do:
#1. Convert Each Country OECD EMG data to long format
#Function to Pivot EMG Df
EMG_pivot = function(dat, cname){
names(dat)[1] = 'OECD Country' #Change Column Name to avoid Duplication
# Pivot the dataframe longer for years
dat = pivot_longer(dat, cols = c(2:ncol(dat)),
names_to = "Year", values_to = cname)
dat$Year = as.numeric(dat$Year)
return(dat)
}
AFG_OECD_EMG = EMG_pivot(AFG_OECD_EMG, 'Afghanistan')
BGD_OECD_EMG = EMG_pivot(BGD_OECD_EMG, 'Bangladesh')
BTN_OECD_EMG = EMG_pivot(BTN_OECD_EMG, 'Bhutan')
MLD_OECD_EMG = EMG_pivot(MLD_OECD_EMG, 'Maldives')
IND_OECD_EMG = EMG_pivot(IND_OECD_EMG, 'India')
NPL_OECD_EMG = EMG_pivot(NPL_OECD_EMG, 'Nepal')
PAK_OECD_EMG = EMG_pivot(PAK_OECD_EMG, 'Pakistan')
SLK_OECD_EMG = EMG_pivot(SLK_OECD_EMG, 'Sri Lanka')
#2. Merge all country dfs to one df with colnames(OECD Country, Year, AFG:SLK)
EMG_dat = cbind(AFG_OECD_EMG, 'Bangladesh' = BGD_OECD_EMG$Bangladesh,
'Bhutan' = BTN_OECD_EMG$Bhutan, 'India' = IND_OECD_EMG$India, 'Maldives' = MLD_OECD_EMG$Maldives,
'Nepal' = NPL_OECD_EMG$Nepal, 'Pakistan' = PAK_OECD_EMG$Pakistan,
'Sri Lanka' = SLK_OECD_EMG$`Sri Lanka`)library(RColorBrewer)
vis3 = EMG_dat %>% filter(Year == 2019) %>% select(-c("Afghanistan"))
# Convert dataframe to long format
vis3 = vis3 %>% pivot_longer(cols = Bangladesh:`Sri Lanka`,
names_to = "Country",
values_to = "Migrants")
# Create plotly plot
plot = plotly::plot_ly()
# Generate color sequence
colors = brewer.pal(length(unique(vis3$`OECD Country`)), "Set2")
# Add traces for each country
for (i in seq_along(unique(vis3$`OECD Country`))) {
country = unique(vis3$`OECD Country`)[i]
country_data = vis3 %>% filter(`OECD Country` == country)
plot = plot %>% add_trace(data = country_data,
x = ~Country,
y = ~Migrants,
name = country,
type = "bar",
marker = list(color = colors[i]),
visible = ifelse(country %in% c("United States", "United Kingdom"
, "Germany", "Australia", "Canada"), TRUE, "legendonly"))
}
# Add layout
layout(plot, title = "Number of Migrants from South Asian Countries to OECD Countries in 2019",
xaxis = list(title = "Country"), yaxis = list(title = "Number of Migrants"),
barmode = "stack")#Calculate total Migrants
OECD_tot = vis3 %>% group_by(Country) %>% summarise(Total = sum(Migrants))
#stargazer(OECD_tot, title = "Summary of Total Emmigrants to OECD Country in 2019", align = TRUE)
OECD_totThe line plot provided an overview of the migration pattern from 2000 to 2021, but it lacked information on the destination countries. To address this, we examine the Number of Migrants from South Asian Countries to OECD Countries specifically in 2019. This visualization offers insights into whether there is a higher proportion of skilled workers migrating from these countries. By assuming that individuals traveling to OECD countries are predominantly skilled workers, we can use the bar plot and the accompanying table to gain insights into labor migration in countries with negative Net Migration in 2019.
For example, out of the 344,000 people who emigrated from Bangladesh in 2019, 53,233 migrated to OECD countries. Similarly, out of the 592,435 people from India, 94,897 from Sri Lanka, 70,597 from Nepal, and 1.18 million from Pakistan, 406,854, 24,985, 48,667, and 97,248 respectively migrated to OECD countries. This implies that approximately 15.4% of people from Bangladesh, 68.67% from India, 26.3% from Sri Lanka, 68.9% from Nepal, and 8.26% from Pakistan migrated to OECD countries in 2019.
These numbers suggest that there is a higher proportion of skilled workers migrating to OECD countries from India, Nepal, and Sri Lanka compared to Bangladesh and Pakistan. This finding prompts further investigation into the reasons behind this migration trend and the determinants driving it. Additionally, it raises the question of whether this mass migration has improved the conditions in the home countries or left them worse off. Understanding these dynamics will contribute to our overall research on migration and its impact on the home countries.
# Function to Clean World Bank Data
clean_wb_dat = function(dat, colname){
colnames(dat) = dat[3,]
dat = dat[-c(1:3),-c(3,4)]
#Subset
df = dat %>% filter(`Country Code` %in% c('AFG', 'BGD', 'BTN',
'IND', 'MDV', 'NPL',
'PAK', 'LKA')) %>%
select(c(1,2, 43:ncol(dat)))
#Pivot Longer
df = pivot_longer(df, cols = 3:ncol(df),
names_to = "Year", values_to = colname)
df[, c(colname)] = sapply(df[, c(colname)], as.numeric)
df$Year = as.numeric(df$Year)
return(df)
}#Inflation Data
inflation_dat = read_excel('inflation.xls')
SAARC_inf = clean_wb_dat(inflation_dat, "Inflation, consumer prices (annual %)")
SAARC_inf = SAARC_inf %>% fill(`Inflation, consumer prices (annual %)`,
.direction = "downup")
#Foreign Direct Investment
FDI = read_excel('FDI.xls')
SAARC_fdi = clean_wb_dat(FDI, 'Foreign direct investment, net inflows (% of GDP)')
#GDPC
GDPC = read_excel('GDPC.xls')
SAARC_gdpc = clean_wb_dat(GDPC, 'GDP per capita (current US$)')
#----------------------------------------------------------------------------
#Literacy Rate
LIT = read_excel('literacy_Rate.xls')
SAARC_lit = clean_wb_dat(LIT, 'Literacy rate, adult total (% of people ages 15 and above)')
colnames(SAARC_lit) = c("Country", "Code", "Year", "Lit_Rate")
#Convert to Factor
SAARC_lit$Country = as.factor(SAARC_lit$Country)
SAARC_lit$Year = as.factor(SAARC_lit$Year)
SAARC_lit$Code = as.factor(SAARC_lit$Code)
# Define a function to impute missing values for a given country
impute_country = function(country_data) {
# Use mice to impute missing values for the given country
imputed = mice(country_data, method = "norm.nob", m = 20, maxit = 50, seed = 123, printFlag = FALSE)
# Extract the completed dataset from the imputed object
completed = complete(imputed)
# Return the completed dataset
return(completed)
}
# Group the dataframe by Country Code
grouped = split(SAARC_lit, SAARC_lit$Code)
# Apply the impute_country function to each group
imputed_list = lapply(grouped, impute_country)
# Bind the imputed dataframes for each country into a single dataframe
imputed_df = do.call(rbind, imputed_list)
imputed_df = data.frame(lapply(imputed_df, as.character), stringsAsFactors=FALSE)
imputed_df$Year = as.numeric((imputed_df$Year))
imputed_df$Lit_Rate = as.numeric(imputed_df$Lit_Rate)
names(imputed_df)[2] = "Country Code"
#------------------------------------------------------------------------------
#Poverty
POV = read_excel('poverty.xls')
colnames(POV) = POV[3,]
POV = POV[-c(1:3),]
#Subset
SAARC_poverty = POV %>% filter(`Country Code` %in% c('AFG', 'BGD', 'BTN',
'IND', 'MDV', 'NPL',
'PAK', 'LKA') & `Indicator Code` %in%
c('SI.POV.MDIM.XQ', 'SI.POV.GINI', 'EN.POP.SLUM.UR.ZS')) %>%
select(c(1:4, 45:ncol(POV)))
#Pivot Longer
SAARC_poverty = pivot_longer(SAARC_poverty, cols = 5:ncol(SAARC_poverty),
names_to = "Year", values_to = )
#------------------------------------------------------------------------------
#Remittance
REM = read_excel('Remittance.xls')
SAARC_remit = clean_wb_dat(REM, 'Personal remittances, received (% of GDP)')
#Unemployment
UNEMP = read_excel('Unemployment.xls')
SAARC_unemployment = clean_wb_dat(UNEMP, 'Unemployment, total (% of total labor force)')
SAARC_unemployment = SAARC_unemployment %>% fill(`Unemployment, total (% of total labor force)`
,.direction = "downup")
#Political Stability Data
PSD = read_excel("Governance.xlsx")
PSD = PSD[-c(25:nrow(PSD)),]
#Rename Columns
names(PSD)[5:26] = c(2000, (2002:2021))
#Pivot Longer
PSD = pivot_longer(PSD, cols = 5:ncol(PSD),
names_to = "Year", values_to = 'Value')
# Pivot from long to wide format
PSD = PSD %>%
pivot_wider(names_from = "Series Name", values_from = "Value")
# Combine the resulting data
SAARC_psd = PSD %>% select(-c("Series Code")) %>%
group_by(`Country Code`, Year) %>%
summarise_all(funs(first(na.omit(.)))) %>%
ungroup()
#Convert Year to Numeric
SAARC_psd$Year = as.numeric(SAARC_psd$Year)
#HDI
HDI = read_excel('HDI_2.xlsx') #Contains HDI data till 2019
HDI_recent = read_excel('HDI.xlsx')#Contains HDI data for 2020 and 2021
#Filter Data
SAARC_hdi = HDI %>% filter(Economy %in% c("Afghanistan", 'Bangladesh',
'Bhutan', 'India', 'Maldives',
'Nepal', 'Pakistan', 'Sri Lanka')) %>%
select(-c(as.character(2020:2023)))
#Rename Column for Left Join
names(SAARC_hdi)[1] = 'Country'
#Clean Data
colnames(HDI_recent) = HDI_recent[4, ]
HDI_recent = HDI_recent[-c(1:5),c('HDI rank', 'Country','2020', '2021')]
#Filter Data
HDI_recent = HDI_recent %>% filter(Country %in% c("Afghanistan", 'Bangladesh',
'Bhutan', 'India', 'Maldives',
'Nepal', 'Pakistan', 'Sri Lanka'))
#Left Join to get data from 2000-2021
SAARC_hdi = left_join(SAARC_hdi, HDI_recent %>% select(c('Country', '2020', '2021')),
by = 'Country')
#Pivot Longer
SAARC_hdi[, 4:ncol(SAARC_hdi)] = apply(SAARC_hdi[, 4:ncol(SAARC_hdi)], 2, as.numeric)
SAARC_hdi = pivot_longer(SAARC_hdi, cols = 4:ncol(SAARC_hdi),
names_to = "Year", values_to = 'HDI index')
SAARC_hdi = SAARC_hdi[,-c(2,3)]
#Add Country Code
SAARC_hdi$"Country Code" = countrycode(sourcevar = SAARC_hdi$Country, origin = "country.name", destination = "iso3c")
SAARC_hdi$Year = as.numeric(SAARC_hdi$Year)
#Median Age
SAARC_mAge = expand.grid(2000:2021, c('AFG', 'BGD', 'BTN',
'IND', 'MDV', 'NPL',
'PAK', 'LKA'))
colnames(SAARC_mAge) = c("Year", "Country Code")
mAge = read.csv('medianAge.csv')
#Add Country Code
mAge$"Country Code" = countrycode(sourcevar = mAge$`Region.Country`, origin = "country.name", destination = "iso3c")
#Left Join
SAARC_mAge = left_join(SAARC_mAge, mAge %>% select(-c("Region.Country")), by=c("Year", "Country Code"))
#Change Colname
names(SAARC_mAge)[2] = "Country_Code"
# Define a function to impute missing values for a given country
impute_country_age = function(country_data) {
# Use mice to impute missing values for the given country
imputed = mice(country_data, method = "norm", m = 5, maxit = 50, printFlag = F)
# Extract the completed dataset from the imputed object
completed = complete(imputed)
# Return the completed dataset
return(completed)
}
# Group the dataframe by Country Code
grouped = split(SAARC_mAge, SAARC_mAge$Country_Code)
# Apply the impute_country function to each group
imp = lapply(grouped, impute_country_age)
# Bind the imputed dataframes for each country into a single dataframe
SAARC_mAge = do.call(rbind, imp)
#Change COlname
names(SAARC_mAge)[2] = "Country Code"#Merge all Data into one DF (2005 to 2021)
SAARC_dat = left_join(SAARC_fdi, select(SAARC_gdpc, -c("Country Name")),
by = c("Country Code", "Year")) %>%
left_join(., select(SAARC_hdi, -c("Country")), by = c("Country Code", "Year"))%>%
left_join(., select(SAARC_inf, -c("Country Name")), by = c("Country Code", "Year"))%>%
left_join(., select(imputed_df, -c("Country")), by = c("Country Code", "Year"))%>%
left_join(., select(SAARC_remit, -c("Country Name")), by = c("Country Code", "Year")) %>%
left_join(., select(SAARC_unemployment, -c("Country Name")), by = c("Country Code", "Year")) %>%
left_join(., SAARC_mAge, by = c("Country Code", "Year")) %>%
left_join(., select(SAARC_psd, -c("Country Name")), by = c("Country Code", "Year")) %>%
left_join(., select(NTMG_SARC, -c("Country Name")), by = c("Country Code", "Year"))
SAARC_dat = SAARC_dat %>% filter(Year > 2004 & `Country Code` != 'AFG') The previous visualization has inspired us to delve deeper into the factors influencing Net Migration and to examine whether migration itself is advantageous for home countries. In pursuit of this goal, we have constructed a comprehensive Correlation Heatmap that depicts the relationships between various factors and Net Migration. Additionally, we acknowledge the likelihood of remittances being sent to family members or friends as a result of any form of migration, and we aim to explore the potential correlation between Remittances and the Human Development Index (HDI). The Correlation Heatmap is distinct for each country and can be easily navigated through the dropdown menu, providing a detailed analysis of the interconnections between different variables.
#Produce Heatmap
#Rename Column Names
colnames(SAARC_dat) = c("Country Name", "Country Code", "Year",
"FDI", "GDPC", "HDI", "Inflation", "Literacy Rate",
"Remittance", "Unemployment", "Age", "Corruption",
"Governance", "Poltical Stability", "Net Migration")
# Create function to filter data by country
filter_by_country = function(df, country) {
filtered_df = df %>%
filter(`Country Name` == country) %>%
select(-`Country Name`, -Year, -`Country Code`)
cor_mat = cor(filtered_df)
return(cor_mat)
}
# Create list of country options for dropdown menu
country_options = unique(SAARC_dat$`Country Name`)
# Create initial plot with first country in list
initial_country = country_options[1]
plot_data = filter_by_country(SAARC_dat, initial_country)
p = plot_ly(
z = plot_data,
x = colnames(plot_data),
y = rownames(plot_data),
type = "heatmap"
)
# Add dropdown menu to plot
p = p %>% layout(
title = "Correlation Heatmap of Different Factors",
xaxis = list(title = "Factors"),
yaxis = list(title = "Factors"),
hovermode = "closest",
showlegend = F,
updatemenus = list(
list(
y = 1.2,
buttons = lapply(country_options, function(country) {
data = filter_by_country(SAARC_dat, country)
list(
method = "restyle",
label = country,
args = list(list(z = list(data), x = list(colnames(data)), y = list(rownames(data))))
)
})
)
)
)
# Display plot
pThe correlation heatmap provides intriguing insights into the factors related to net migration in different countries. We observe strong positive correlations are observed between net migration and factors such as political stability, governance, literacy rate, Human Development Index (HDI), and Gross Domestic Product per capita (GDPC) for Bangladesh, Bhutan, India, and Nepal. These findings suggest that countries with better political stability, governance, higher literacy rates, higher HDI, and higher GDPC tend to experience higher net migration, indicating improved opportunities and living conditions. On the contrary, Sri Lanka, Maldives, and Pakistan show negative correlations between HDI, GDPC, and net migration, potentially indicating a “brain drain” phenomenon where individuals with higher skills and qualifications are more likely to migrate.
Interestingly, corruption and unemployment demonstrate positive correlations with net migration in Bangladesh, Nepal, and Bhutan, implying that as corruption and unemployment increase, more people tend to migrate to these countries. Although counterintuitive, this might be attributed to rent-seeking behavior, where individuals or groups seek economic advantages through non-productive means. In contrast, Pakistan, Maldives, and India exhibit negative correlations, suggesting that people tend to leave these countries when corruption and unemployment rise. Additionally, India and Nepal show a positive correlation between age and net migration, indicating that as young people grow older, they tend to return to their home countries, possibly due to retirement or a desire to reconnect with family and cultural roots.
Furthermore, examining the correlation of remittance with other factors sheds light on its impact on home countries. It is observed that higher levels of HDI, literacy rate, and GDPC in Bangladesh, India, and Maldives are associated with lower levels of remittance, suggesting reduced reliance on remittances as these countries develop. Conversely, higher inflation rates in Bangladesh, India, and Maldives are linked to higher levels of remittance. This maybe due to the fact that remittances provide households with more consumption capability. Additionally, Bhutan, Nepal, and Pakistan exhibit higher levels of remittance with higher levels of HDI, literacy rate, and GDPC, indicating that increased inflows of remittances coincide with economic growth and development in these countries.
Nevertheless, it is crucial to note that these inference are speculative and based on potential correlations. Further research and analysis are necessary to establish concrete causality and to gain a more comprehensive understanding of the factors driving migration patterns and the impact of remittance on home countries.
From the visualizations above and to bettter understand the relationship of Net Migration with these factors we devise a linear regression model. Here, Net Migration is the dependent variable with GDP Per Capita, Human Development Index, Literacy Rate, Age, Inflation Rate, Unemployment Rate, Corruption, Governance, Political Stability and the interaction of GDP Per Capita and Literacy Rate as independent variables. In particular we want to see how socio-economic and political factors affect Net Migration for each country.
\[ \text{Net Migration} = \beta_0 + \beta_1 \cdot \text{GDP Per Capita} + \beta_2 \cdot \text{HDI} + \beta_3 \cdot \text{Literacy Rate} + \beta_4 \cdot \text{Age} + \beta_5 \cdot \text{Inflation Rate} + \beta_6 \cdot \text{Unemployment Rate} + \beta_7 \cdot \text{Corruption} + \beta_8 \cdot \text{Governance} + \beta_9 \cdot \text{Political Stability} + \beta_{10} \cdot(\text{GDP Per Capita} \times \text{Literacy Rate}) + \varepsilon \]
The regression result for each country can be selected from the drop down menu below.
library(htmltools)
create_regression_tables = function(formula, data, country_codes) {
# Fit regression models
fits = lapply(country_codes, function(country_code) {
lm(formula, data = data %>% filter(`Country Code` == country_code))
})
# Create a list of regression tables
regression_tables = lapply(seq_along(fits), function(i) {
paste(capture.output(stargazer(fits[[i]], type = 'html', out = tempfile(), dep.var.labels = 'Net Migration', covariate.labels = c(
'GDP Per Capita', 'Human Development Index', 'Literacy Index', 'Age', 'Inflation Rate', 'Unemployment Rate', 'Corruption', 'Political Stability', 'Governance', 'GDP Per Capita x Literacy Rate'
))), collapse = '')
})
names(regression_tables) = paste0("Regression Table For ", (country_codes))
return(regression_tables)
}
# Example usage
formula = `Net Migration` ~ `GDPC` + `HDI` + `Literacy Rate` + `Age` + `Inflation` + `Unemployment` + `Corruption` + `Poltical Stability` + `Governance` + `GDPC` * `Literacy Rate`
country_codes = c('BGD', 'BTN',
'IND', 'MDV', 'NPL',
'PAK', 'LKA')
regression_tables = create_regression_tables(formula, SAARC_dat, country_codes)
# Create the drop-down menu
dropdown_menu = tags$select(
id = "table_select",
class = "form-control",
onchange = "updateTable()",
lapply(names(regression_tables), function(table_name) {
tags$option(table_name)
})
)
# Display the drop-down menu
dropdown_menu# Create a div to display the selected table
div(id = "table_output", style = "margin-top: 20px;")# JavaScript code to update the table based on the selected option
js_code = paste0("
var regressionTables = ", jsonlite::toJSON(regression_tables), ";
function updateTable() {
var tableSelect = document.getElementById('table_select');
var selectedTable = tableSelect.options[tableSelect.selectedIndex].text;
var outputDiv = document.getElementById('table_output');
outputDiv.innerHTML = regressionTables[selectedTable];
}
updateTable();
")
# Include the JavaScript code
tags$script(HTML(js_code))# Add CSS styles to center the table
tags$style(HTML("
#table_output table {
margin: auto;
}
"))The regression results indicate that several factors have significant associations with net migration in the respective countries. In Bangladesh, higher GDP per capita and an older population are associated with positive net migration, while lower literacy rates and inflation rates are linked to positive net migration. Higher levels of corruption and unemployment rates also contribute to positive net migration, whereas higher political stability and better governance are associated with negative net migration. The interaction between GDP per capita and literacy rate is not significant. These findings suggest that economic, demographic, and socio-political factors play a significant role in shaping net migration patterns in Bangladesh.
In Bhutan, the regression results highlight that a higher age is negatively related to net migration, indicating that as the population ages, more people tend to leave the country relative to coming in. Improved political stability is positively sloped with net migration, suggesting its attractive to individuals. However, the other variables, including GDP per capita, literacy rate, corruption, unemployment rate, governance, and the interaction between GDP per capita and literacy rate, do not significantly predict net migration. The model explains around 68% of the variation in net migration, with an adjusted R-squared value of 0.680.
For India, the only significant variable is the unemployment rate, which has a positive coefficient implying as higher unemployment leads to increase in Net Migration. Other variables included in the model do not have a significant association with net migration. This implies that factors such as GDP per capita, age, literacy rate, inflation rate, corruption, political stability, governance, and the interaction between GDP per capita and literacy rate do not play a significant role in predicting net migration. This is further illustrated by the relatively low adjusted R-squared value of 0.378.
In the case of Maldives, none of the individual variables in the model have a significant association with net migration, except for governance, which has a negative coefficient and is significant at p<0.05. This suggests that better governance is associated with lower net migration in Maldives. The adjusted R-squared value of the model is 0.617, indicating that it explains approximately 61.7% of the variation in net migration.
Similarly, the regression results for Nepal indicate that none of the individual variables have a significant association with net migration, except for the unemployment rate, which has a positive coefficient and is significant at p<0.05. This implies that a higher unemployment rate is associated with positive net migration in Nepal. The adjusted R-squared value is 0.788, indicating that the model explains approximately 78.8% of the variation in net migration.
For Pakistan, only the inflation rate variable has a significant association with net migration at p<0.05, with a positive coefficient. This suggests that higher inflation rates are associated with positive net migration. However, the other variables in the model, including GDP per capita, age, literacy rate, corruption, unemployment rate, political stability, governance, and the interaction between GDP per capita and literacy rate, are not significant predictors of net migration. The adjusted R-squared value is 0.52, indicating that the model explains approximately 52% of the variation in net migration.
In Sri Lanka, the regression results show that only the corruption variable has a significant association with net migration at p<0.05, with a negative coefficient. This implies that higher levels of corruption are associated with negative net migration in Sri Lanka. However, the other variables, including GDP per capita, age, literacy rate, inflation rate, unemployment rate, political stability, governance, and the interaction between GDP per capita and literacy rate, are not significant predictors of net migration. The model explains around 80.8% of the variation in net migration, with an adjusted R-squared value of 0.808.
Nevertheless, it is important to note that the regression analysis establishes relation between variables and net migration, but it does not imply causation. The identified associations suggest a relationship between the variables and net migration patterns, but other unmeasured factors or correlations could also be influencing the observed results. Therefore, the results are not concrete and inference should not be solely based on these regression results.
Furthermore, we also ran a fixed effect linear regression analysis to examine the relationship between HDI (Human Development Index) and the variables Remittance, Foreign Direct Investment (FDI), Literacy Rate, Inflation Rate, GDP Per Capita (GDPC), and Political Stability across the countries: Bangladesh, Bhutan, India, Maldives, Nepal, Pakistan, and Sri Lanka. The standard errors were clustered to account for potential within-group dependencies.
\[ \text{Human Development Index (HDI)} = \beta_0 + \beta_1 \cdot \text{GDP Per Capita} + \beta_2 \cdot \text{Inflation Rate} + \beta_3 \cdot \text{Literacy Rate} + \beta_4 \cdot \text{Foreign Direct Investment} + \beta_5 \cdot \text{Political Stability} + \beta_6 \cdot \text{Remittance} + \varepsilon \]
#Regression
library(lfe)
# Run fixed effects regression
fe_model = felm(HDI ~ Remittance + FDI + `Literacy Rate` + Inflation +
GDPC + `Poltical Stability` | `Country Name` | 0 | `Country Name`,
data = SAARC_dat)
# View summary of results
stargazer(fe_model, type='html', style = 'aer', dep.var.labels = 'Human Development Index', covariate.labels = c(
'Remitance', 'Foreign Direct Investment', 'Literacy Rate', 'Inflation Rate', 'GDP Per Capita', 'Political Stability'
))| Human Development Index | |
| Remitance | 0.004 |
| (0.002) | |
| Foreign Direct Investment | -0.003 |
| (0.003) | |
| Literacy Rate | 0.002* |
| (0.001) | |
| Inflation Rate | 0.000 |
| (0.001) | |
| GDP Per Capita | 0.000** |
| (0.000) | |
| Political Stability | 0.015 |
| (0.016) | |
| Observations | 119 |
| R2 | 0.944 |
| Adjusted R2 | 0.938 |
| Residual Std. Error | 0.022 (df = 106) |
| Notes: | ***Significant at the 1 percent level. |
| **Significant at the 5 percent level. | |
| *Significant at the 10 percent level. | |
The results indicate that Remittance and FDI do not have a statistically significant impact on HDI. However, Literacy Rate is found to be statistically significant at the p<0.1 level, with a positive coefficient. This suggests that higher literacy rates are associated with higher HDI values on average in these countries.
Additionally, GDPC is found to be statistically significant at the p<0.05 level, with a coefficient of 0.000, which makes sense as HDI value ranges from 0 to 1. This indicates that an increase in GDPC is associated with a positive effect on HDI. On the other hand, Political Stability does not show a statistically significant relationship with HDI in this analysis. This means that variations in Political Stability across the countries in the sample do not appear to have a consistent impact on HDI.
The adjusted R-squared value of 0.938 indicates that the model explains approximately 93.8% of the variation in HDI, suggesting a good fit. Yet, it is important to note that while these findings provide valuable insights into the relationship between HDI and the included variables, they do not establish causality. The analysis reveals associations rather than direct causal effects.
Although the visualizations and regression analysis illustrate the socio-economic and political factor affecting migration and its effect on Home countries, it is important to acknowledge the limitations inherent in the interpretation of the findings. The regression results, which form a significant part of the analysis, are subject to certain limitations. The explanatory power of the regression models varies across countries, as indicated by adjusted R-squared values ranging from 0.378 to 0.808. These values suggest that a considerable portion of the variation in net migration remains unexplained by the variables included in the models. Moreover, the models only consider a specific set of variables, potentially overlooking other influential factors such as social and cultural dynamics, government policies, and external events. Additionally, it should be recognized that the significance of variables may fluctuate over time, and the results are based on a particular time period and context. These limitations should be taken into account when interpreting and generalizing the findings.
In conclusion, the visualizations and regression analyses conducted in this report shed light on the factors influencing migration and its impact on home countries. The findings indicate that political stability, governance, literacy rate, GDP per capita, and age are significant factors associated with net migration. While, we assumed that unemployment, literacy rate, and corruption significantly contribute to the migration of individuals from these countries, the relationship between migration and variables such as corruption, unemployment, and literacy rate varies among the countries analyzed.
Furthermore, we also believed that remittances would have a positive impact on these countries rather than being disadvantageous. However, the analysis of remittance revealed its relation with human development, literacy rate, and GDP per capita in different countries but remittances itself were insignificant for HDI. Nevertheless, we saw that some countries experience reduced reliance on remittances as they develop, others see increased inflows of remittances coinciding with economic growth. This highlights the complex interplay of socio-economic and political factors in driving migration patterns and emphasizes the need for further research to establish causality and gain a comprehensive understanding of migration’s effects.
Ultimately, this research contributes to the broader understanding of migration dynamics and its implications for SAARC countries. By identifying the factors influencing migration and exploring the impact on home countries, policymakers and stakeholders can make informed decisions to address brain drain, enhance opportunities, and create environments that encourage individuals to contribute to their home nations’ development.
Ustubici, Aysen, and Darja Irdam. The Impact of Remittances on International Relations Department Human, economics-sociology.eu/files/Ustubici_Irdam%20V5N1.pdf. Accessed 19 May 2023.
Chang, Shirley L. “Causes of Brain Drain and Solutions: The Taiwan Experience - Studies in Comparative International Development.” SpringerLink, link.springer.com/article/10.1007/BF02687103. Accessed 19 May 2023.
Easterly, William, and Yaw Nyarko. “Is the Brain Drain Good for Africa?” SSRN, 18 Apr. 2008, papers.ssrn.com/sol3/papers.cfm?abstract_id=1121853.
Sutradhar, Soma Rani. “The Impact of Remittances on Economic Growth in Bangladesh, India, Pakistan and Sri Lanka - International Journal of Economic Policy Studies.” SpringerLink, 31 Jan. 2020, link.springer.com/article/10.1007/s42495-020-00034-1.
https://data.worldbank.org/indicator/BX.TRF.PWKR.DT.GD.ZS?locations=8S
https://data.worldbank.org/indicator/NY.GDP.PCAP.CD?locations=8S
https://data.worldbank.org/indicator/BX.KLT.DINV.WD.GD.ZS?locations=8S
http://hdr.undp.org/en/composite/trends
https://data.worldbank.org/indicator/FP.CPI.TOTL.ZG?locations=8S
https://en.wikipedia.org/wiki/Human_Development_Index
https://stats.oecd.org/Index.aspx?DataSetCode=MIG#
https://kidb.adb.org/go/rt-human-development-index
#DAG
library(dagitty)
# Create nodes
nodes = dagitty("dag{
GDP_Per_Capita -> Net_Migration
Human_Development_Index -> Net_Migration
Literacy_Rate -> Net_Migration
Median_Age -> Net_Migration
Inflation_Rate -> Net_Migration
Unemployment_Rate -> Net_Migration
Corruption -> Net_Migration
Violence -> Net_Migration
Governance -> Net_Migration
GDP_Per_Capita -> Literacy_Rate
}")
#Set Coordinates
coordinates(nodes) = list(x = c(Human_Development_Index = 2, GDP_Per_Capita = 1.5,
Literacy_Rate = 1, Median_Age = 1,
Inflation_Rate = 1, Unemployment_Rate= 1.6,
Corruption = 1, Violence = 1.05, Governance = 1.2,
Net_Migration = 2),
y = c(Human_Development_Index = 4, GDP_Per_Capita = 1.5,
Literacy_Rate = 1, Median_Age = 3,
Inflation_Rate = 3.5, Unemployment_Rate= 4.5,
Corruption = 4, Violence = 4.5, Governance = 4.8,
Net_Migration = 1))
#PLot
plot(nodes)# Create nodes
nodes_1 = dagitty("dag{
GDP_Per_Capita -> Human_Development_Index
Foreign_Direct_Investment -> Human_Development_Index
Literacy_Rate -> Human_Development_Index
Remittance -> Human_Development_Index
Inflation_Rate -> Human_Development_Index
}")
#Set Coordinates
coordinates(nodes_1) = list(x = c(Human_Development_Index = 2, GDP_Per_Capita = 1,
Literacy_Rate = 1, Inflation_Rate = 1,
Remittance = 1.5, Foreign_Direct_Investment = 1),
y = c(Human_Development_Index = 1, GDP_Per_Capita = 1,
Literacy_Rate = 1.5, Inflation_Rate = 2,
Remittance = 2.5, Foreign_Direct_Investment = 2.5))
#PLot
plot(nodes_1)# Extract fixed effects for each country
fixed_effects = getfe(fe_model)
# View fixed effects
fixed_effects